/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package impss;

import java.sql.*;

/**
 *
 * @author Mikehood
 */
public class DBAdapter {

    String url = "jdbc:mysql://localhost:3306/impss";
    String name = "root";
    String password = "password12345";
    Connection conn;
    Statement stat;
    ResultSet rs;
    boolean succed;

    public boolean isSuccessful() {
        return succed;
    }

    public ResultSet executeQuery(String sql) {
        succed = true;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(url, name, password);
            stat = conn.createStatement();
            rs = stat.executeQuery(sql);
        } catch (ClassNotFoundException cnfex) {
            succed = false;
        } catch (SQLException e) {
            succed = false;
        }
        return rs;
    }

    public void execute(String sql) {
        succed = true;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(url, name, password);
            stat = conn.createStatement();
            stat.execute(sql);
        } catch (ClassNotFoundException cnfex) {
            succed = false;
        } catch (SQLException e) {
            succed = false;
        }
    }

    public DBAdapter() {
    }
}
